﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CoreUtils.WIL
{
    /// <summary>
    /// Morphology operations
    /// </summary>
    public class Morphology
    {
        public static FVIL.Data.CFviImage Erosion(FVIL.Data.CFviImage src)
        {
            FVIL.Data.CFviImage dst = new FVIL.Data.CFviImage();
            FVIL.Morphology.CFviErosion parser = new FVIL.Morphology.CFviErosion(src, dst);
            parser.Validate();
            parser.StructureElements[0].CreateBoxSE(3, 3);
            parser.Execute();
            return dst;
        }

        public static FVIL.Data.CFviImage Dilation(FVIL.Data.CFviImage src)
        {
            FVIL.Data.CFviImage dst = new FVIL.Data.CFviImage();
            FVIL.Morphology.CFviDilation parser = new FVIL.Morphology.CFviDilation(src, dst);
            parser.Validate();
            parser.StructureElements[0].CreateBoxSE(3, 3);
            parser.Execute();
            return dst;
        }

        public static FVIL.Data.CFviImage Closing(FVIL.Data.CFviImage src)
        {
            FVIL.Data.CFviImage dst = new FVIL.Data.CFviImage();
            FVIL.Morphology.CFviClosing parser = new FVIL.Morphology.CFviClosing(src, dst);
            parser.Validate();
            parser.StructureElements[0].CreateBoxSE(3, 3);
            parser.Execute();
            return dst;
        }

        public static FVIL.Data.CFviImage Opening(FVIL.Data.CFviImage src)
        {
            FVIL.Data.CFviImage dst = new FVIL.Data.CFviImage();
            FVIL.Morphology.CFviOpening parser = new FVIL.Morphology.CFviOpening(src, dst);
            parser.Validate();
            parser.StructureElements[0].CreateBoxSE(3, 3);
            parser.Execute();
            return dst;
        }
    }
}
